<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获得连接状态</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-connection-reset.html">pg_connection_reset</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-convert.html">pg_convert</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.pg-connection-status" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_connection_status</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_connection_status</span> &mdash; <span class="dc-title">
     获得连接状态
    </span></p>

   </div>
   <div class="refsect1 unknown-seealsp" id="refsect1-function.pg-connection-status-unknown-seealsp">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="type">int</span> <span class="methodname"><strong>pg_connection_status</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
     )</div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_connection_status()</strong></span> 返回一个连接的状态。可能的状态为
     <em>PGSQL_CONNECTION_OK</em> 和 <em>PGSQL_CONNECTION_BAD</em>。
    </p>
    <p class="para">
     <div class="example" id="example-2019">
      <p><strong>Example #1 <span class="function"><strong>pg_connection_status()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$stat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connection_status</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'connection_status:&nbsp;'</span><span style="color: #007700">.</span><span style="color: #0000BB">$stat</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

     </div>
    </p>
    <p class="para">
     <div class="example" id="example-2020">
      <p><strong>Example #2 <span class="function"><strong>pg_connection_status()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$stat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connection_status</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'connection_status:&nbsp;'</span><span style="color: #007700">.</span><span style="color: #0000BB">$stat</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

     </div>
    </p>
    <p class="para">
     参见 <span class="function"><a href="function.pg-connection-busy.html" class="function">pg_connection_busy()</a></span>。
    </p>
   </div>

  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-connection-reset.html">pg_connection_reset</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-convert.html">pg_convert</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
